package com.zt.dev.processMonitoring.service.impl;

import com.zt.dev.processMonitoring.mapper.TaskProcessMapper;
import com.zt.dev.processMonitoring.pojo.TaskProcess;
import com.zt.dev.processMonitoring.pojo.TaskProcessDTO;
import com.zt.dev.processMonitoring.pojo.TaskProcessDictionaries;
import com.zt.dev.processMonitoring.service.TaskProcessService;
import lombok.AllArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author 卜德凯
 * @date 2020/3/10 18:24
 */
@Service
public class TaskProcessServiceImpl implements TaskProcessService {

    @Autowired
    private TaskProcessMapper taskProcessMapper;

    /**
     * 创建的流程放到流程字典表（task_process_dictionaries）中以便下次直接选用
     * @param processNode
     * @return
     */
    @Override
    public Integer addProcess(String processNode) {
        return taskProcessMapper.addProcess(processNode);
    }

    /**
     * 根据被选的id获取字典表（task_process_dictionaries）中相应的流程
     * @param dictionariesId
     * @return
     */
    @Override
    public TaskProcessDictionaries findProcess(Integer dictionariesId) {
        return taskProcessMapper.findProcess(dictionariesId);
    }

    /**
     * 创建评估任务流程
     * @param processList
     * @return
     */
    @Override
    public Integer createProcess(List<TaskProcess> processList) {
        return taskProcessMapper.createProcess(processList);
    }

    /**
     * 查看已有评估流程的任务
     * @return
     */
    @Override
    public List<TaskProcessDTO> seeTaskProcess() {
        return taskProcessMapper.seeTaskProcess();
    }

    /**
     * 根据taskId和userId查看具体的流程
     * @return
     */
    @Override
    public List<TaskProcess> seeSpecificProcess(Integer taskId,Integer userId) {
        return taskProcessMapper.seeSpecificProcess(taskId,userId);
    }

    /**
     * 根据流程id更新流程节点的状态
     * @param taskProcess
     * @return
     */
    @Override
    public Integer updateProcessStatus(TaskProcess taskProcess) {
        return taskProcessMapper.updateProcessStatus(taskProcess);
    }
}
